

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Fortran 90 derived-type support &mdash; quippy 7ea04c5+ documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
        <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"processClass": "math|output_area", "processEscapes": true, "ignoreClass": "document", "inlineMath": [["$", "$"], ["\\(", "\\)"]]}})</script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/theme_overrides.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="prev" title="patch_f2py — modify numpy.f2py at runtime" href="patch_f2py.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> quippy
          

          
            
            <img src="_static/hybrid.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                7ea04c5+
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
    
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction to <code class="docutils literal notranslate"><span class="pre">quippy</span></code></a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation of QUIP and quippy</a></li>
<li class="toctree-l1"><a class="reference internal" href="Tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="quippy.html">Quippy library reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="visualisation.html">Visualisation Tools</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="fortran_wrapper.html">Appendix: wrapping Fortran 90 Code</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="f90doc.html"><code class="docutils literal notranslate"><span class="pre">f90doc</span></code> — Fortran 90 source code scanner</a></li>
<li class="toctree-l2"><a class="reference internal" href="f2py_wrapper_gen.html"><code class="docutils literal notranslate"><span class="pre">f2py_wrapper_gen</span></code> — Fortran 90 source code wrapping</a></li>
<li class="toctree-l2"><a class="reference internal" href="patch_f2py.html"><code class="docutils literal notranslate"><span class="pre">patch_f2py</span></code> — modify <code class="docutils literal notranslate"><span class="pre">numpy.f2py</span></code> at runtime</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Fortran 90 derived-type support</a><ul class="simple">
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="teach_sparse.html">Command line options of the teach_sparse main program</a></li>
</ul>

            
          
    <p></p>
    <ul>
        <li><a href="genindex.html">Index</a></li>
        <li><a href="py-modindex.html">Module Index</a></li>
        <li><a href="search.html">Search Page</a></li>
        <li><a href="_modules/index.html">Module Source Code</a></li>
    </ul>
  
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">quippy</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
          <li><a href="fortran_wrapper.html">Appendix: wrapping Fortran 90 Code</a> &raquo;</li>
        
      <li>Fortran 90 derived-type support</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/oo_fortran.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  
<style>
/* CSS overrides for sphinx_rtd_theme */

/* 24px margin */
.nbinput.nblast,
.nboutput.nblast {
    margin-bottom: 19px;  /* padding has already 5px */
}

/* ... except between code cells! */
.nblast + .nbinput {
    margin-top: -19px;
}

.admonition > p:before {
    margin-right: 4px;  /* make room for the exclamation icon */
}

/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
    text-align: unset;
}
</style>
<div class="section" id="module-quippy.oo_fortran">
<span id="fortran-90-derived-type-support"></span><h1>Fortran 90 derived-type support<a class="headerlink" href="#module-quippy.oo_fortran" title="Permalink to this headline">¶</a></h1>
<p>Object oriented interface on top of f2py generated wrappers.</p>
<p>This module adds support for derived types to f2py generated modules,
providing the Fortran source code was built using
<a class="reference internal" href="f2py_wrapper_gen.html#module-f2py_wrapper_gen" title="f2py_wrapper_gen: Generate simplified Fortran 90 source suitable for f2py"><code class="xref py py-mod docutils literal notranslate"><span class="pre">f2py_wrapper_gen</span></code></a>.</p>
<p>Module contents for <a class="reference internal" href="#module-quippy.oo_fortran" title="quippy.oo_fortran: Fortran 90 derived-type support"><code class="xref py py-mod docutils literal notranslate"><span class="pre">quippy.oo_fortran</span></code></a>:</p>
<p class="rubric">Classes</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-obj docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a>(*args,&nbsp;**kwargs)</td>
<td>Abstract base class for all fortran derived types.</td>
</tr>
</tbody>
</table>
<p class="rubric">Functions</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.oo_fortran.wrap_all" title="quippy.oo_fortran.wrap_all"><code class="xref py py-obj docutils literal notranslate"><span class="pre">wrap_all</span></code></a>(fobj,&nbsp;spec,&nbsp;mods,&nbsp;merge_mods,&nbsp;…)</td>
<td>Returns tuple <cite>(classes, routines, params)</cite> suitable for importing into top-level package namespace.</td>
</tr>
</tbody>
</table>
<p class="rubric">Attributes</p>
<table border="1" class="docutils">
<colgroup>
<col width="84%" />
<col width="16%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><a class="reference internal" href="#quippy.oo_fortran.FortranDerivedTypes" title="quippy.oo_fortran.FortranDerivedTypes"><code class="xref py py-attr docutils literal notranslate"><span class="pre">FortranDerivedTypes</span></code></a></td>
<td>—</td>
</tr>
</tbody>
</table>
<dl class="class">
<dt id="quippy.oo_fortran.FortranDerivedType">
<em class="property">class </em><code class="descclassname">quippy.oo_fortran.</code><code class="descname">FortranDerivedType</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract base class for all fortran derived types.</p>
<p>This class is an abstract base class for all Fortran
derived-types. It contains all the magic necessary
to communicate with a module wrapped using the
<a class="reference internal" href="f2py_wrapper_gen.html#module-f2py_wrapper_gen" title="f2py_wrapper_gen: Generate simplified Fortran 90 source suitable for f2py"><code class="xref py py-mod docutils literal notranslate"><span class="pre">f2py_wrapper_gen</span></code></a> module.</p>
<p>The constructor invokes a Fortran interface or routine to initialise
the object. When the reference count for instances of this class drops to zero,
the destructor frees the associated Fortran derived type.</p>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType.is_same_fortran_object" title="quippy.oo_fortran.FortranDerivedType.is_same_fortran_object"><code class="xref py py-obj docutils literal notranslate"><span class="pre">is_same_fortran_object</span></code></a>(other)</td>
<td>Test if <cite>self</cite> and <cite>other</cite> point to the same Fortan object.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType.shallow_copy" title="quippy.oo_fortran.FortranDerivedType.shallow_copy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">shallow_copy</span></code></a>()</td>
<td>Return a shallow copy of <cite>self</cite>.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType.shallow_copy_from" title="quippy.oo_fortran.FortranDerivedType.shallow_copy_from"><code class="xref py py-obj docutils literal notranslate"><span class="pre">shallow_copy_from</span></code></a>(other)</td>
<td>Transform <cite>self</cite> into a shallow copy of <cite>other</cite>.</td>
</tr>
</tbody>
</table>
<p>Important attributes and methods are as follows:</p>
<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._fpointer">
<code class="descname">_fpointer</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._fpointer" title="Permalink to this definition">¶</a></dt>
<dd><p>Pointer to underlying Fortran derived type instrance, or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
not initialised.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._routines">
<code class="descname">_routines</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._routines" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping routine names to tuples <cite>(fortran_object, specification)</cite>.
Used by <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._runroutine" title="quippy.oo_fortran.FortranDerivedType._runroutine"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_runroutine()</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._interfaces">
<code class="descname">_interfaces</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._interfaces" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping interface names to a list of 3-tuples <cite>(name, specification, fortran_object)</cite>.
Used by <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._runinterface" title="quippy.oo_fortran.FortranDerivedType._runinterface"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_runinterface()</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._elements">
<code class="descname">_elements</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._elements" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping Fortran element names to tuple <cite>(get_routine, set_routine)</cite>.
A property is created for each entry in <cite>_elements</cite> which invokes <cite>get_routine</cite>
and <cite>set_routine</cite> automatically.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._subobjs">
<code class="descname">_subobjs</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._subobjs" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping names of component objects to tuples <cite>(get_routine, set_routine)</cite>.
Used by <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._update" title="quippy.oo_fortran.FortranDerivedType._update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_update()</span></code></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedType._arrays">
<code class="descname">_arrays</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._arrays" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping names of arrays to tuples <cite>(array_func, doc_string)</cite>. Used by
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._update" title="quippy.oo_fortran.FortranDerivedType._update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_update()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType._runroutine">
<code class="descname">_runroutine</code><span class="sig-paren">(</span><em>name</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType._runroutine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._runroutine" title="Permalink to this definition">¶</a></dt>
<dd><p>Internal method used to invoke the Fortran routine <cite>name</cite></p>
<p><cite>name</cite> must be a valid key in <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._routines" title="quippy.oo_fortran.FortranDerivedType._routines"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_routines</span></code></a>. Wrapper
methods which simply call <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._runroutine" title="quippy.oo_fortran.FortranDerivedType._runroutine"><code class="xref py py-meth docutils literal notranslate"><span class="pre">_runroutine()</span></code></a> are
automatically generated in subclasses of
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a> by <a class="reference internal" href="#quippy.oo_fortran.wrap_all" title="quippy.oo_fortran.wrap_all"><code class="xref py py-func docutils literal notranslate"><span class="pre">wrap_all()</span></code></a>.</p>
<p>Input arguments which are instances of a subclass of
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a> are replaced by their
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._fpointer" title="quippy.oo_fortran.FortranDerivedType._fpointer"><code class="xref py py-attr docutils literal notranslate"><span class="pre">_fpointer</span></code></a> integer attribute.</p>
<p>If there is an keyword argument with the name <cite>args_str</cite>
then unexpected keyword arguments are permitted. All the
undefined keyword arguments are collected together to form a
dictionary which is converted to string form and used as the the
<cite>arg_string</cite> argument, providing rudimentary support for
variable numbers and types of arguments. For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">p</span> <span class="o">=</span> <span class="n">Potential</span><span class="p">(</span><span class="s1">&#39;IP SW&#39;</span><span class="p">,</span> <span class="n">xml_string</span><span class="p">)</span>
    <span class="n">p</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">virial</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">energy</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
<p>is equivalent to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">p</span> <span class="o">=</span> <span class="n">Potential</span><span class="p">(</span><span class="s1">&#39;IP SW&#39;</span><span class="p">,</span> <span class="n">xml_string</span><span class="p">)</span>
    <span class="n">p</span><span class="o">.</span><span class="n">calc</span><span class="p">(</span><span class="n">at</span><span class="p">,</span> <span class="n">args_str</span><span class="o">=</span><span class="s2">&quot;virial energy&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>The return value us made up of a tuple of the arguments to the
Fortran routine which are <code class="docutils literal notranslate"><span class="pre">intent(out)</span></code>. Pointers to Fortran
derived-type instances are replaced with new instances of the
appropriate subclass of <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a>. Arrays
are converted to use one-based indexing using
<a class="reference internal" href="farray.html#quippy.farray.FortranArray" title="quippy.farray.FortranArray"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranArray</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType._runinterface">
<code class="descname">_runinterface</code><span class="sig-paren">(</span><em>name</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType._runinterface"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._runinterface" title="Permalink to this definition">¶</a></dt>
<dd><p>Internal method used to invoke the appropriate routine
within the Fortran interface <cite>name</cite>. If no routine is found
matching the names and types of the arguments provided then
an <code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code> exception is raised.</p>
<p>Arguments and results are handled in the same way as
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType._runroutine" title="quippy.oo_fortran.FortranDerivedType._runroutine"><code class="xref py py-func docutils literal notranslate"><span class="pre">_runroutine()</span></code></a>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType._update">
<code class="descname">_update</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType._update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._update" title="Permalink to this definition">¶</a></dt>
<dd><p>Automatically invoked whenever this object needs to be
updated. This happens when it is first created, when it is
direcly passed to a Fortran routine with <code class="docutils literal notranslate"><span class="pre">intent(in,out)</span></code> or
when it is a component of another object which is passed with
<code class="docutils literal notranslate"><span class="pre">intent(in,out)</span></code>.</p>
<p>This method also invokes all the hook in the
<code class="xref py py-attr docutils literal notranslate"><span class="pre">_update_hooks</span></code> list. This can be used in subclasses to
allow a customised response. For example this mechanism is used
in <code class="xref py py-class docutils literal notranslate"><span class="pre">quippy.extras.Atoms</span></code> to update Atoms properties.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType._get_array_shape">
<code class="descname">_get_array_shape</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType._get_array_shape"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType._get_array_shape" title="Permalink to this definition">¶</a></dt>
<dd><p>This method can be used to override Fortran’s idea of the shape of
arrays within derived types, for example to present only a partial
view of an array. This is used in <a class="reference internal" href="table.html#quippy.table.Table" title="quippy.table.Table"><code class="xref py py-class docutils literal notranslate"><span class="pre">quippy.table.Table</span></code></a>
to allow the sizes of arrays within the Table class to correspond to the
current extent of the Table, rather than the size of the allocated storage
which will usually be larger.</p>
<p>If this method returns <code class="docutils literal notranslate"><span class="pre">None</span></code> then the full array is presented, otherwise
the return value should be a tuple <cite>(N_1, N_2, …, N_d)</cite> where <cite>d</cite>
is the number of dimensions of the array and <cite>N_1, N_2</cite> etc. are the lengths
of each dimension.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType.is_same_fortran_object">
<code class="descname">is_same_fortran_object</code><span class="sig-paren">(</span><em>other</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType.is_same_fortran_object"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType.is_same_fortran_object" title="Permalink to this definition">¶</a></dt>
<dd><p>Test if <cite>self</cite> and <cite>other</cite> point to the same Fortan object.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType.shallow_copy">
<code class="descname">shallow_copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType.shallow_copy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType.shallow_copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow copy of <cite>self</cite>.</p>
</dd></dl>

<dl class="method">
<dt id="quippy.oo_fortran.FortranDerivedType.shallow_copy_from">
<code class="descname">shallow_copy_from</code><span class="sig-paren">(</span><em>other</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#FortranDerivedType.shallow_copy_from"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedType.shallow_copy_from" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform <cite>self</cite> into a shallow copy of <cite>other</cite>.</p>
</dd></dl>

</dd></dl>

<dl class="function">
<dt id="quippy.oo_fortran.wrap_all">
<code class="descclassname">quippy.oo_fortran.</code><code class="descname">wrap_all</code><span class="sig-paren">(</span><em>topmod</em>, <em>spec</em>, <em>mods</em>, <em>short_names</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/quippy/oo_fortran.html#wrap_all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#quippy.oo_fortran.wrap_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns tuple <cite>(classes, routines, params)</cite> suitable for
importing into top-level package namespace. <cite>topmod</cite> should be an
f2py-generated module containing <cite>fortran</cite> objects, and <cite>spec</cite>
should be the specification dictionary generated by
<a class="reference internal" href="f2py_wrapper_gen.html#f2py_wrapper_gen.wrap_mod" title="f2py_wrapper_gen.wrap_mod"><code class="xref py py-func docutils literal notranslate"><span class="pre">f2py_wrapper_gen.wrap_mod()</span></code></a>.  <cite>mods</cite> is a list of the names
of Fortran modules to wrap, and <cite>short_names</cite> is a dictionary
mapping shortened Fortran derived-type names to their canonical
form.</p>
<p><cite>classes</cite> and <cite>routines</cite> are lists of <cite>(name, value)</cite> tuples
where <cite>value</cite> is a newly defined subclass of
<a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a> or newly wrapped routine respectively.
<cite>params</cite> is a Python dictionary of Fortran parameters (constants).</p>
<p>Here’s how this function is used in quippy’s <code class="file docutils literal notranslate"><span class="pre">__init.py__</span></code> to
import the new classes, routines and params into the top-level quippy
namespace:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">classes</span><span class="p">,</span> <span class="n">routines</span><span class="p">,</span> <span class="n">params</span> <span class="o">=</span> <span class="n">wrap_all</span><span class="p">(</span><span class="n">_quippy</span><span class="p">,</span> <span class="n">spec</span><span class="p">,</span> <span class="n">spec</span><span class="p">[</span><span class="s1">&#39;wrap_modules&#39;</span><span class="p">],</span> <span class="n">spec</span><span class="p">[</span><span class="s1">&#39;short_names&#39;</span><span class="p">])</span>

<span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="bp">cls</span> <span class="ow">in</span> <span class="n">classes</span><span class="p">:</span>
   <span class="nb">setattr</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="vm">__name__</span><span class="p">],</span> <span class="n">name</span><span class="p">,</span> <span class="bp">cls</span><span class="p">)</span>

<span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">routine</span> <span class="ow">in</span> <span class="n">routines</span><span class="p">:</span>
   <span class="nb">setattr</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="vm">__name__</span><span class="p">],</span> <span class="n">name</span><span class="p">,</span> <span class="n">routine</span><span class="p">)</span>

<span class="n">sys</span><span class="o">.</span><span class="n">modules</span><span class="p">[</span><span class="vm">__name__</span><span class="p">]</span><span class="o">.</span><span class="vm">__dict__</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="attribute">
<dt id="quippy.oo_fortran.FortranDerivedTypes">
<code class="descclassname">quippy.oo_fortran.</code><code class="descname">FortranDerivedTypes</code><a class="headerlink" href="#quippy.oo_fortran.FortranDerivedTypes" title="Permalink to this definition">¶</a></dt>
<dd><p>Dictionary mapping Fortran type names in format <code class="docutils literal notranslate"><span class="pre">type(lower_case_name)</span></code> to
classes derived from <a class="reference internal" href="#quippy.oo_fortran.FortranDerivedType" title="quippy.oo_fortran.FortranDerivedType"><code class="xref py py-class docutils literal notranslate"><span class="pre">FortranDerivedType</span></code></a>.</p>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
      
        <a href="patch_f2py.html" class="btn btn-neutral float-left" title="patch_f2py — modify numpy.f2py at runtime" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2008-2016, James Kermode

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>